package com.ssy.lingxi.logistics.model.request;

import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
import java.io.Serializable;
import java.util.List;

/**
 * 物流单请求实体
 * @author yzc
 * @version 2.0.0
 * @date 2020/7/20
 */
@Data
public class LogisticsOrderRequest implements Serializable {

    private static final long serialVersionUID = -4801836694007673279L;

    /**
     * 主键id
     */
    @NotNull(message = "主键id不能为空", groups = {Update.class})
    private Long id;

    /**
     * 单据摘要
     */
    @NotEmpty(message = "单据摘要不能为空", groups = {Add.class, Update.class})
    private String digest;

    /**
     * 物流服务商id
     */
    @NotNull(message = "物流服务商id不能为空", groups = {Add.class, Update.class})
    private Long companyId;

    /**
     * 物流服务商名称
     */
    private String companyName;

    /**
     * 发货单id
     */
    private Long shipmentOrderId;

    /**
     * 发货单号
     */
    private String shipmentOrderCode;

    /**
     * 对应订单id
     */
    private Long relevanceOrderId;

    /**
     * 对应单据编号
     */
    private String relevanceOrderCode;

    /**
     * 对应单据类型 1-销售订单 2-换货申请单(退货发货) 3-换货申请单(换货发货) 4-退货申请单
     */
    private Integer relevanceType;

    /**
     * 发货方地址id
     */
    private Long shipperAddressId;

    /**
     * 发货方名称
     */
    private String shipperName;

    /**
     * 发货方手机
     */
    private String shipperPhone;

    /**
     * 发货方全地址
     */
    private String shipperFullAddress;

    /**
     * 收货方会员id
     */
    private Long receiverMemberId;

    /**
     * 收货方会员角色id
     */
    private Long receiverRoleId;

    /**
     * 收货方会员名称
     */
    private String receiverMemberName;

    /**
     * 收货方地址id
     */
    private Long receiverAddressId;

    /**
     * 收货人全地址
     */
    private String receiverFullAddress;

    /**
     * 收货方名称
     */
    private String receiverName;

    /**
     * 收货方手机
     */
    private String receiverPhone;

    /**
     * 结算方式
     */
    private String settlementWay;

    /**
     * 创建方式 1-物流能力创建 2-销售发货订单创建 3-生产通知订单创建 4-换货申请创建 5-换货处理创建 6-退货申请创建
     */
    private Integer createType;

    /**
     * 物流单明细列表
     */
    @Valid
    private List<LogisticsOrderDetailRequest> detailList;

    public interface Add {
    }

    public interface Update {
    }

    @Data
    public static class LogisticsOrderDetailRequest implements Serializable {

        private static final long serialVersionUID = 7775190457407568988L;

        /**
         * 商品id
         */
        @NotNull(message = "商品id不能为空", groups = {Add.class, Update.class})
        private Long productId;

        /**
         * 商品名称
         */
        @NotEmpty(message = "商品名称不能为空", groups = {Add.class, Update.class})
        private String productName;

        /**
         * 类别名称
         */
        @NotEmpty(message = "类别名称不能为空", groups = {Add.class, Update.class})
        private String categoryName;

        /**
         * 品牌名称
         */
        private String brandName;

        /**
         * 单位名称
         */
        @NotEmpty(message = "单位名称不能为空", groups = {Add.class, Update.class})
        private String unitName;

        /**
         * 数量
         */
        @Positive(message = "数量要大于0", groups = {Add.class, Update.class})
        private Double amount;

        /**
         * 箱数
         */
        @Positive(message = "箱数要大于0", groups = {Add.class, Update.class})
        private Double carton;

        /**
         * 重量
         */
        private Double weight;

        /**
         * 体积
         */
        private Double volume;

    }
}
